﻿using Project.API.Models.AuthModels;
using Project.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace Project.API.Controllers.AuthControllers
{
    public class AuthController : ApiController
    {
        // GET: api/Auth
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }
        //获取用户权限
        // GET: api/Auth/5
        public ResultData<List<AuthorizeDto>> Get(int id)
        {
            var list = new AuthorityBll().GetAuthorities(id);
            var data = from l in list
                       select new AuthorizeDto
                       {
                           authID = l.authID,
                           roleID = l.roleID,
                           menuID=l.menuID,
                           menuName=l.Menus.menuName,
                       };
            ResultData<List< AuthorizeDto>> result = new ResultData<List<AuthorizeDto>>();
            result.data = data.ToList();
            result.code = 0;
            result.msg = "ok";
            return result;
        }

        // POST: api/Auth
        public void Post([FromBody]string value)
        {
        }

        // PUT: api/Auth/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE: api/Auth/5
        public void Delete(int id)
        {
        }
    }
}
